// 下载页面axios请求

import axios from "../apiWrapper";

// 请求Django
export const downloadFromDjango = ()=>{
    let url = "http://localhost:8081/django/search/"
    return axios.get(url)
}



// 通过关键词下载数据
export const downloadByTerm = (term)=>{
    let url = `http://localhost:8081/PMC/crawl.json?spider_name=PMC&start_requests=true&crawl_args={"mode":"1","term":"${term}}"}`
    return axios.get(url)
};

// 翻页
export const downloadByTurnPage = (page)=>{
    let url = `http://localhost:8081/PMC/crawl.json?spider_name=PMC&start_requests=true&crawl_args={"mode":"2","currPage":"${page}"}`
    return axios.get(url)
};


// 下载文章到数据库
export const downloadText = (list) => {

    // 构造参数
    let PMCID = list.join()

    let url = `http://localhost:8081/PMC/crawl.json?spider_name=PMC&start_requests=true&crawl_args={"mode":"3","PMCID":"${PMCID}"}`;

    return axios({
        method: "get",
        url: url,
        timeout: 30000,
    })
};
